﻿using System;
using System.Windows.Forms;
using TpContracts;
using TpData.Manager;
using TpOffice.Controller;
using TpOffice.Interfaces;

namespace TpOffice.Forms {

    public partial class MainForm : Form, ITecForm {

        #region Members

        MainController controller;

        #endregion

        #region Constructor

        public MainForm() {
            this.controller = new MainController(this);
            InitializeComponent();
            SetEventHandler();
            SetUserLoginText(Contracts.MyUser.UserName, Contracts.MyUser.LoginTime);
            SetFormTitle();
        }

        #endregion

        #region Methods

        private void BeforeClosing(object sender, FormClosingEventArgs e) {
            this.controller.BeforeClosing(sender, e);
        }

        private void ChangeUser(object sender, EventArgs e) {
            this.controller.ChangeUser(sender, e);
        }

        private void CloseForm(object sender, EventArgs e) {
            this.controller.CloseForm(sender, e);
        }

        private void OpenBusinessCasesShortListForm(object sender, EventArgs e) {
            this.controller.OpenBusinessCasesShortListForm(sender, e);
        }

        private void OpenCashSale(object sender, EventArgs e) {
            this.controller.OpenCashSaleForm(sender, e);
        }

        private void OpenImportForm(object sender, EventArgs e) {
            this.controller.OpenImportForm(sender, e);
        }

        private void ProgramInfo(object sender, EventArgs e) {
            this.controller.ShowCommingSoon();
        }

        private void SetEventHandler() {
            this.btnBusinessCases.Click += new EventHandler(OpenBusinessCasesShortListForm);
            this.btnBarverkauf.Click += new EventHandler(OpenCashSale);
            this.btnImportBMD.Click += new EventHandler(OpenImportForm);
        }

        private void SetFormTitle() {
            this.Text = "Tec-Office (" + Application.ProductVersion + ")" ;
        }

        public void SetUserLoginText(string userName, DateTime loginTime) {
            this.toolStripStatusLabel1.Text = userName + " Login: " + loginTime.ToString("yy-MM-dd HH:mm:ss");
        }

        #endregion

        #region Form Events

        

        #endregion

        #region Overrides

        public override string ToString() {
            return this.Text;
        }

        #endregion

    }
}
